﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;


using KingRoad.EPM.PersonnelLogEntity.Model;
using Unis.Framework.Core.Utility;
using KingRoad.EPM.PersonnelLogDAL.PlmPersonnelinforecordService;


namespace KingRoad.EPM.PersonnelLogBLL.UIRules
{
    /// <summary> 
    /// 客户端业务处理类。 
    /// 文件生成时间 2017/1/12 13:58:16
    /// </summary> 
    public class PlmPersonnelinforecordUIRule
    {
        private readonly IPlmPersonnelinforecordService _plmPersonnelinforecordService;
        
        
        public PlmPersonnelinforecordUIRule(){}
        
        /// <summary> 
        /// construct function... 
        /// </summary> 
        public PlmPersonnelinforecordUIRule(IPlmPersonnelinforecordService plmPersonnelinforecordService)
        {
            _plmPersonnelinforecordService = plmPersonnelinforecordService;
        }

        /// <summary>
        /// 获取人员信息
        /// </summary>
        /// <returns></returns>
        public List<PlmPersonnelinforecordInfo> GetAllPersonnelinfo(string condition = " 1=1 ")
        {
            var list = _plmPersonnelinforecordService.GetEntityList(condition);
            return list;
        }
        /// <summary>
        /// 根据条件查询信息
        /// </summary>
        /// <param name="numCurrentPage">当前页</param>
        /// <param name="numPerPage">每页数据大小</param>
        /// <param name="orderByField">排序字段名称</param>
        /// <param name="totalRecord">总数据量</param>
        /// <param name="sqlCondition">sql查询条件</param>
        /// <returns></returns>
        public List<PlmPersonnelinforecordInfo> GetAllCostplanmainForPage(int numCurrentPage, int numPerPage,
                                                                        string orderByField, out int totalRecord, string sqlCondition)
        {
            var list = _plmPersonnelinforecordService.GetEntityListByContionRe(numCurrentPage, numPerPage, orderByField, out totalRecord, sqlCondition);
            return list;
        }
        /// <summary>
        /// 获取人员信息 根据ID获取
        /// </summary>
        /// <returns></returns>
        public PlmPersonnelinforecordInfo GetPersonnelinfoByID(Guid id)
        {
            var list = _plmPersonnelinforecordService.GetEntityById(id);
            return list;
        }
        /// <summary>
        /// 根据标段名称 获取该标段人员信息
        /// </summary>
        /// <param name="section"></param>
        /// <returns></returns>
        public List<PlmPersonnelinforecordInfo> GetPersonlInfoBySectionName(string section)
        {
            var list = _plmPersonnelinforecordService.GetEntityList("Pi_unitId='" + section + "'");
            return list;
        }

        /// <summary>
        /// 添加人员信息
        /// </summary>
        /// <returns></returns>
        public int AddPersonnelinfo(PlmPersonnelinforecordInfo AddEntity)
        {
            return _plmPersonnelinforecordService.InsertEntity(AddEntity);
        }

        /// <summary>
        /// 删除人员信息
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public int DeletePersonnelinfo(string id)
        {
            return _plmPersonnelinforecordService.DeleteEntityByStringID(id);
        }

        /// <summary>
        /// 删除人员信息(批量删除)
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public int DeletePersonnelinfoMulti(string id)
        {
            return _plmPersonnelinforecordService.DeleteEntityByMultiStringID(id);
        }

        /// <summary>
        /// 更新人员信息
        /// </summary>
        /// <returns></returns>
        public int UpdatePersonnelinfo(PlmPersonnelinforecordInfo UpdateEntity)
        {
            return _plmPersonnelinforecordService.UpdateEntity(UpdateEntity);
        }

        /// <summary>
        /// 获取所有的人员信息
        /// </summary>
        /// <param name="numCurrentPage">当前页</param>
        /// <param name="numPerPage">每页数据大小</param>
        /// <param name="orderByField">排序字段名称</param>
        /// <param name="totalRecord">总数据量</param>
        /// <returns></returns>
        public List<PlmPersonnelinforecordInfo> GetAllPersonnelinfo(int numCurrentPage, int numPerPage, string orderByField, out int totalRecord)
        {
            var list = _plmPersonnelinforecordService.GetEntityListByContion(numCurrentPage, numPerPage, orderByField, out totalRecord);
            return list;
        }

        /// <summary>
        /// 根据条件查询人员信息
        /// </summary>
        /// <param name="numCurrentPage">当前页</param>
        /// <param name="numPerPage">每页数据大小</param>
        /// <param name="orderByField">排序字段名称</param>
        /// <param name="totalRecord">总数据量</param>
        /// <param name="sqlCondition">sql查询条件</param>
        /// <returns></returns>
        public List<PlmPersonnelinforecordInfo> GetPersonnelinfoForSearch(int numCurrentPage, int numPerPage,
                                                                        string orderByField, out int totalRecord, string sqlCondition)
        {
            var list = _plmPersonnelinforecordService.GetEntityListByContion(numCurrentPage, numPerPage, orderByField, out totalRecord, sqlCondition);
            return list;
        }
    }
}
